from crawler_core.event.timer.schedule_task import startApi, startDown, startLogin, startSearch, startEventDown, \
    startEventSearch, startEventSearchSecond
from lib.constant.lib_constant import LibConstant
from lib.init.system_init import SystemInit
from lib.setting.setting import Setting
from threading import Thread
from multiprocessing import Pool

class CrawlerInit:
    SERVER_API = LibConstant.SERVER_API
    SERVER_DOWN = LibConstant.SERVER_DOWN
    SERVER_LOGIN = LibConstant.SERVER_LOGIN
    SERVER_SEARCH = LibConstant.SERVER_SEARCH

    @staticmethod
    def start(server_name):
        Setting.add_properties()
        SystemInit.start(server_name)
        if server_name == CrawlerInit.SERVER_API:
            # 开启API服务
            startApi()

        if server_name == CrawlerInit.SERVER_DOWN:
            # 开启下载服务
            startDown()

        if server_name == CrawlerInit.SERVER_SEARCH:
            # 开启查询服务
            startSearch()

        if server_name == CrawlerInit.SERVER_LOGIN:
            # 开启登录服务
            startLogin()
        return True
